import {
  createStore
} from 'vuex'
import axios from 'axios'
import persist from 'vuex-persistedstate'
export default createStore({
  state: {
    objList: []
  },
  mutations: {
    add(state, value) {
      state.objList.unshift({
        name: value,
        id: new Date().getTime(),
        check: false
      })
      console.log(state.objList);
    },
    change() {},
    remove(state, i) {
      state.objList.splice(i, 1)
    },

  },

  getters: {
    trueLength(state) {
      return state.objList.reduce((num, item) => num += item.check, 0)
    },
    falseLength(state) {
      return state.objList.reduce((num, item) => num += !item.check, 0)

    }
  },
  actions: {


  },
  plugins: [persist()]


})